<template>
    <div class="photoinfo-container">
        <h3>{{photoinfo.title}}</h3>
        <p class="subtitle">
            <span>发表时间:{{photoinfo.ptime}}</span>
            <span>点击次数:2次</span>
        </p>
        <hr>
        <!-- 缩略图区域 -->
        <!-- {{photoinfo.picInfo[0].url}} -->
        <!-- <img :src="photoinfo.picInfo[0].url" alt=""> -->
        <vue-preview :slides="slide1" @close="handleClose" ></vue-preview>
        <!-- 图片文字内容区域 -->
        <div class="content">
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
            {{photoinfo.digest}}
        </div>

        <!-- 放置一个现成的评论子组件 -->
        <!-- 3 放置子组件 -->
        <comment></comment>
    </div> 
</template>


<script>
// 1.先导入评论子组件
import comment from '../subcomponents/comment.vue'
export default {
    data(){
        return{
            category:this.$route.params.category,
            index:this.$route.params.index,//从路由中获取的当前点击图片的index值
            photoinfo:{},//图片详情
            slide1: [
                {
                    src: '',
                    msrc: '',
                    alt: 'picture1',
                    title: '',
                    w: 600,
                    h: 400
                },
                {
                    src: '',
                    msrc: '',
                    alt: 'picture2',
                    title: '',
                    w: 600,
                    h: 400
                },
                // {
                //     src: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_b.jpg',
                //     msrc: 'https://farm4.staticflickr.com/3902/14985871946_86abb8c56f_m.jpg',
                //     alt: 'picture2',
                //     title: 'Image Caption 2',
                //     w: 1200,
                //     h: 900
                // }
            ]
        }
    },
    created(){
        this.getPhotoInfo()
    },
    methods:{
        getPhotoInfo(){
            // 获取图片的详情页
            this.$http.get('https://www.apiopen.top/journalismApi').then(res=>{
                if(res.body.code===200){
                    this.photoinfo = res.body.data[this.category][this.index-1]
                    
                    this.slide1[0].msrc =this.slide1[0].src = this.photoinfo.picInfo[0].url;
                    this.slide1[0].title = this.photoinfo.picInfo[0].title;
                    
                    this.slide1[1].msrc =this.slide1[1].src = this.photoinfo.picInfo[0].url;
                    this.slide1[1].title = this.photoinfo.picInfo[0].title;

                }
            })
        },
        handleClose () {
        console.log('close event')
        }
    },
    components:{// 2.在注册子组件
        comment:comment
    }
}
</script>


<style lang="scss">
// 真是一个大坑！！！！我们把scoped属性去掉后才能修改mui自带的图片样式
.photoinfo-container{
    padding: 3px;
    h3{
        font-size: 16px;
        text-align: center;
        margin:15px 0;
    }
    p{
        display: flex;
        justify-content: space-between;
        font-size: 12px;
    }
    div{
        .my-gallery{
            figure{
                margin: 10px;
                img{
                    width: 100%;
                }
            }
        }
    }
    .content{
        font-size: 12px;
        text-indent: 2em;
    }
}
</style>
